package com.bw.controller;

import com.bw.entity.Bing;
import com.bw.entity.Dict;
import com.bw.mapper.BingMapper;
import org.spring.kun.common.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class BingController {

    @Autowired
    BingMapper bingMapper;


    @RequestMapping("/tuPage.do")
    public String tuPage(Model model) {

        List<Dict> sourceList = bingMapper.listSource();
        model.addAttribute("sourceList", sourceList);
        return "tu";
    }

    @RequestMapping("/bing.do")
    @ResponseBody
    public List<Bing> bing(Integer sourceId, String status) {

        List<Bing> bingList = bingMapper.bing(sourceId, status);

        return bingList;
    }

    @RequestMapping("/excel.do")
    public void excel(Integer sourceId, String status, HttpServletResponse response) {

        List<Bing> bingList = bingMapper.bing(sourceId, status);

        ExcelUtils.exportExcel(bingList, "人才信息统计表", "人才信息统计表", response);
    }
}
